<?php
require_once("dbconnection.php"); 
require_once("baseclass.php");
require_once("definitions.php");
require_once("../ajaxify/uploadclass.php");
class ADMIN extends BASECLASS {   
  
      function getAdminInfo($userid='') {
            if(!$userid) {
                $userid = 1000;
            }
            $query =" select * from ".ADMIN_TABLE." where id = '$userid'";
            $result = mysql_fetch_array(mysql_query($query));
            return $result;
      }
      
      function adminSignIn($formvalue) {
            $admin = new ADMIN;
            
            $formvalue = explode("`",$formvalue);
            $username = $formvalue[0];
            $login_password = $formvalue[1];
            $login = $admin->adminLogin($username,$login_password);
            if (!@$login["id"]) {
                  return ADMIN_LOGIN_ERR;
            } else {
                  if($username == $login["username"]) {
                        $_SESSION["nfa_loginid"] =  $login["id"];
                        $admin->setAdminLoginDetails($login["id"],$login["session_id"]);
                        return true;
                  }
                  if($username != $login["username"]) {
                        return ADMIN_LOGIN_ERR;
                  }
            }
      }

      function enable($data) {
            $data=explode("`",$data);
            $table_name=$data[0];
            $id=$data[1];
            $status=$data[2];
            $query="update $table_name set status='$status' where id='$id'";
            mysql_query($query);
      }
      
      function feature($data) {
            $data=explode("`",$data);
            $table_name=$data[0];
            $id=$data[1];
            $feature=$data[2];
            $query="update $table_name set featured='$feature' where id='$id'";
            mysql_query($query);
      }      
      
      function del($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $table_name=$data[0];
            $id=$data[1];
            $folder=$data[2];            
            $id=explode("~",$id);
            foreach($id as $val) {
                  $query="delete from $table_name where id='$val'";
                  mysql_query($query); 
                  $path="../uploads/$folder/$val/";
                  if(is_dir($path)){
                        $admin->removeDir($path);   
                  }     
            }
      }
	  function delBanner($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $table_name=$data[0];
            $id=$data[1];
            $folder=$data[2];            
            $id=explode("~",$id);
            foreach($id as $val) {
                  $query="delete from $table_name where banner_id='$val'";
                  mysql_query($query); 
                  $path="../uploads/$folder/$val/";
                  if(is_dir($path)){
                        $admin->removeDir($path);   
                  }     
            }
      }
	  
	  function getUploadedContent($upload_content,$folder,$id) {
            $admin = new ADMIN;     
            $layout="";       
            if($upload_content) {
                  $upload_content=unserialize(urldecode($upload_content));                                                  
                  foreach($upload_content as $key => $val) {                        
                        foreach($val as $key1 => $val1) {
                              if($key1!="caption") {
                                    $id_arr[]=$key1;         
                              }
                        }
                  }
                  if($id_arr) {
                        $id_arr=array_unique($id_arr);   
                        $piro_class=0;                   
                        foreach($id_arr as $key => $value) {                                                                                               
                              $lay=null;
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];
                                    $utype = explode("_",$value);                                    
                                    $utype = $utype[0];
                                    if($file && $utype == "uimage") {
                                          $piro_class++;
                                    }
                              }
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];                     
                                    $caption = @$value1['caption'];
                                    $utype = explode("_",$value);
                                    $utype = $utype[0];                                          
                                    if($file) {
                                          if($utype == "uvideo") {
                                                $path = BASEPATH."ajaxify/images/video.jpg"; 
                                                $path = "<img src='$path' class='thumbView' alt='$caption' />";                                               
                                          } else if($utype == "ufile") {
                                                $thumb = explode(".",$file);
                                                $count = count($thumb);
                                                $thumb = $thumb[$count-1];
                                                $path = BASEPATH."ajaxify/images/$thumb.jpg";                                                
                                                $path = "<a href='javascript:void(0)' class='download' name='$id'>$file</a>";
                                          } else {
                                                if($piro_class==1) {
                                                      $class = "pirobox";
                                                } else {
                                                      $class = "pirobox_gall";
                                                }
                                                if(!$caption) {
                                                      $caption ='&nbsp';
                                                }
                                                $path = BASEPATH."uploads/$folder/$id/t1_$file";
                                                $path = "   <a href='javascript:void(0)' id='t4_$file' name='$folder-$id' class='$class' title='$caption'>
                                                                  <img src='$path' class='thumbView' alt='$caption' />
                                                            </a>&nbsp;";                                               
                                          }
                                          $lay .= $path;
                                    }
                              }
                              $layout[$value] = $lay;                                 
                        }                              
                  }                                               
            }                                         
            return $layout;
      }
	  function getUploadedContentVideo($upload_content,$folder,$id) {
            $admin = new ADMIN;     
            $layout="";       
            if($upload_content) {
                  $upload_content=unserialize(urldecode($upload_content));                                                  
                  foreach($upload_content as $key => $val) {                        
                        foreach($val as $key1 => $val1) {
                              if($key1!="caption") {
                                    $id_arr[]=$key1;         
                              }
                        }
                  }
                  if($id_arr) {
                        $id_arr=array_unique($id_arr);   
                        $piro_class=0;                   
                        foreach($id_arr as $key => $value) {                                                                                               
                              $lay=null;
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];
                                    $utype = explode("_",$value);                                    
                                    $utype = $utype[0];
                                    if($file && $utype == "uimage") {
                                          $piro_class++;
                                    }
                              }
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];                     
                                    $caption = @$value1['caption'];
                                    $utype = explode("_",$value);
                                    $utype = $utype[0];                                          
                                    if($file) {
                                          if($utype == "uvideo") {
                                                //$path = BASEPATH."ajaxify/images/video.jpg"; 
                                                //$path = "<img src='$path' class='thumbView' alt='$caption' />";
												$path = BASEPATH."uploads/$folder/$id/$file";
												$path = $admin -> getJWPlayer($path);
												/*$v_name = explode(".",$file);
												if($v_name[1] == "flv"){
													$video = $admin -> getFLVPlayerNew($path,$tmb_pic='',$player_path='',$height='',$width='',$default_play='');
												}else{
													$video = $admin -> getAviPlayer($path,$tmb_pic='',$player_path='',$height='',$width='',$default_play='');
												}*/
												
										} else if($utype == "ufile") {
                                                $thumb = explode(".",$file);
                                                $count = count($thumb);
                                                $thumb = $thumb[$count-1];
                                                $path = BASEPATH."ajaxify/images/$thumb.jpg";                                                
                                                $path = "<a href='javascript:void(0)' class='download' name='$id'>$file</a>";
                                          } else {
                                                if($piro_class==1) {
                                                      $class = "pirobox";
                                                } else {
                                                      $class = "pirobox_gall";
                                                }
                                                if(!$caption) {
                                                      $caption ='&nbsp';
                                                }
                                                $path = BASEPATH."uploads/$folder/$id/t1_$file";
                                                $path = "   <a href='javascript:void(0)' id='t4_$file' name='$folder-$id' class='$class' title='$caption'>
                                                                  <img src='$path' class='thumbView' alt='$caption' />
                                                            </a>&nbsp;";                                               
                                          }
                                          $lay .= $path;
                                    }
                              }
                              $layout[$value] = $path;                                 
                        }                              
                  }                                               
            }                                         
            return $layout;
      }
	  
	  function getUploadedContentVideoImage($upload_content,$folder,$id) {
            $admin = new ADMIN;     
            $layout="";       
            if($upload_content) {
                  $upload_content=unserialize(urldecode($upload_content));                                                  
                  foreach($upload_content as $key => $val) {                        
                        foreach($val as $key1 => $val1) {
                              if($key1!="caption") {
                                    $id_arr[]=$key1;         
                              }
                        }
                  }
                  if($id_arr) {
                        $id_arr=array_unique($id_arr);   
                        $piro_class=0;                   
                        foreach($id_arr as $key => $value) {                                                                                               
                              $lay=null;
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];
                                    $utype = explode("_",$value);                                    
                                    $utype = $utype[0];
                                    if($file && $utype == "uimage") {
                                          $piro_class++;
                                    }
                              }
                              foreach($upload_content as $key1 => $value1) {
                                    $file = $value1[$value];                     
                                    $caption = @$value1['caption'];
                                    $utype = explode("_",$value);
                                    $utype = $utype[0];                                          
                                    if($file) {
                                          if($utype == "uvideo") {
                                                //$path = BASEPATH."ajaxify/images/video.jpg"; 
                                                //$path = "<img src='$path' class='thumbView' alt='$caption' />";
												$path = BASEPATH."uploads/$folder/$id/$file";
												$path = BASEPATH."uploads/$folder/$id/$file";
												$path = $admin -> getJWPlayer($path);
												/*$v_name = explode(".",$file);
												if($v_name[1] == "flv"){
													$path = $admin -> getFLVPlayerNew($path,$tmb_pic='',$player_path='',$height='',$width='',$default_play='');
												}else{
													$path = $admin -> getAviPlayer($path,'','',"0");
												}*/
												
										} else if($utype == "ufile") {
                                                $thumb = explode(".",$file);
                                                $count = count($thumb);
                                                $thumb = $thumb[$count-1];
                                                $path = BASEPATH."ajaxify/images/$thumb.jpg";                                                
                                                $path = "<a href='javascript:void(0)' class='download' name='$id'>$file</a>";
                                          } else {
                                                if($piro_class==1) {
                                                      $class = "pirobox";
                                                } else {
                                                      $class = "pirobox_gall";
                                                }
                                                if(!$caption) {
                                                      $caption ='&nbsp';
                                                }
                                                $path = BASEPATH."uploads/$folder/$id/t1_$file";
                                                $path = "   <a href='javascript:void(0)' id='t4_$file' name='$folder-$id' class='$class' title='$caption'>
                                                                  <img src='$path' class='thumbView' alt='$caption' />
                                                            </a>&nbsp;";                                               
                                          }
                                          $lay .= $path;
                                    }
                              }
                              $layout[$value] = $lay;                                 
                        }                              
                  }                                               
            }                                         
            return $layout;
      }
	  
      /* Common Action End */
      
      /* Site Configuration Start */
      function saveConfiguration($data) {
            $admin = new ADMIN;
            $data = explode("~",$data);
            $key = explode("`",$data[0]);
            $value = explode("`",$data[1]);
            $arr = array_combine($key,$value);
            
            if($arr) {
                  $arr = urlencode(serialize($arr));
            }
            
            $mode = $data[2];
            $id = $data[3];
            
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="all_fields`updated_date";
            $db_values="$arr`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','',CONFIGURATION_TABLE,'id');                  
            }           
            
            $result = $admin -> insertElseUpdate(CONFIGURATION_TABLE,$db_fields,$db_values,'id',$id);
            
            if($result == ADD_MSG) {
                  unset($_SESSION["configuration"]);
                  $result = MSG017;
            } else if($result == UPDATE_MSG) {
                  $result = MSG018;
                  unset($_SESSION["configuration"]);
            } else {             
                  $result = "<span class='emi newerror'>$result</span>";
            }
            
            return $result;
            
      }
      /* Site Configuration End */
      
      /* Content Management Start */
      function getContentDisplayinCombo($control_name,$equal_value='',$class='',$call_fun='',$default_option='') {
            $admin = new ADMIN;            
            $field = "Footer";
            $value = "Footer";
            return $list = $admin -> getComboFromUser($control_name,$field,$value,$rep='',$equal_value,$class,$call_fun='',$default_option);
      }
      
      function contentList($indx,$filter,$ser_display_in,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".CONTENT_MANAGEMENT_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid431'>$page_title</div>
                                          <div class='grid160'>$display_in</div>
                                          <div class='grid60 acenter'>$enabled</div>
                                          <div class='grid40 acenter'>$edit</div>
                                          <div class='grid123 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveContent($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $display_in = $data[0];
            $page_title = $data[1];
            $meta_title = $data[2];
            $meta_keyword = $data[3];
            $meta_description = $data[4];
            $id = $data[5];
            $mode = $data[6];
            $content = $data[7];
                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="display_in`page_title`meta_title`meta_keyword`meta_description`content`updated_date";
            $db_values="$display_in`$page_title`$meta_title`$meta_keyword`$meta_description`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','',CONTENT_MANAGEMENT_TABLE,'id');
                  $result=$admin->isAlreadyExist(CONTENT_MANAGEMENT_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(CONTENT_MANAGEMENT_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(CONTENT_MANAGEMENT_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG010;
            } else if($result==UPDATE_MSG) {
                  $result=MSG011;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
            return $result;
      }
      /* Content Management End */
	  
	  /* Urgent needs start */
	  
	  function urgentList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".URGENT_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveUrgent($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','URG',URGENT_TABLE,'id');
                  $result=$admin->isAlreadyExist(URGENT_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(URGENT_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(URGENT_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG004;
            } else if($result==UPDATE_MSG) {
                  $result=MSG005;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
            return $result;
      }
	  
	  /* Urgent needs end */
	  
	  /* On Going projects start*/
	  
	  function projectList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".PROJECT_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveProject($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
			$short_desc = $data[1];
            $id = $data[2];
            $mode = $data[3];
            $content = $data[4];
			$upload_content = $data[5];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`short_desc`content`updated_date";
            $db_values="$page_title`$short_desc`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','PRO',PROJECT_TABLE,'id');
                  $result=$admin->isAlreadyExist(PROJECT_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(PROJECT_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(PROJECT_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG007;
            } else if($result==UPDATE_MSG) {
                  $result=MSG008;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  /* Urgent needs end */
	  /* Featured start */
	  function saveFeatured($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $short_desc = $data[1];
			$id = $data[2];
            $mode = $data[3];
            $content = $data[4];
			$upload_content = $data[5];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="title`short_desc`content`updated_date";
            $db_values="$page_title`$short_desc`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','FEA',FEATURED_TABLE,'id');
                  $result=$admin->isAlreadyExist(FEATURED_TABLE,'title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(FEATURED_TABLE,'title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(FEATURED_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG039;
            } else if($result==UPDATE_MSG) {
                  $result=MSG040;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  function featuredList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".FEATURED_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  /* Featured end */
	  /* News management start*/
	  
	  function newsList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".NEWS_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid502'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveNews($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];
			$upload_content = $data[4];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','NEWS',NEWS_TABLE,'id');
                  $result=$admin->isAlreadyExist(NEWS_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(NEWS_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(NEWS_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG013;
            } else if($result==UPDATE_MSG) {
                  $result=MSG014;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  /* News management end */
	  
	  /* Accomplishment management start*/
	  
	  function accomplishList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".ACCOMPLISHMENT_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveAccomplishment($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];
			$upload_content = $data[4];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','ACC',ACCOMPLISHMENT_TABLE,'id');
                  $result=$admin->isAlreadyExist(ACCOMPLISHMENT_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(ACCOMPLISHMENT_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(ACCOMPLISHMENT_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG015;
            } else if($result==UPDATE_MSG) {
                  $result=MSG016;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			return $result;
      }
	  
	  /* Accomplishment management end */
	  
	  /* Career start */
	  
	  function careerList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("first_name",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".CAREER_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $name = "<a href='javascript:void(0)' name='$id' class='preview'>$first_name</a>";
                        
                        $layout .= "<li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid215'>$name</div>
                                          <div class='grid225'>$email</div>
                                          <div class='grid100 acenter'>$qualification</div>
										  <div class='grid80 acenter'>$percentage</div>
										  <div class='grid70 acenter'>$experience</div>
                                          <div class='grid113 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  
	  /* Career End */
	  /* Album management start*/
	  
	  function albumList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".ALBUM_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveAlbum($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];
			$upload_content = $data[4];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','ALB',ALBUM_TABLE,'id');
                  $result=$admin->isAlreadyExist(ALBUM_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(ALBUM_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(ALBUM_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG019;
            } else if($result==UPDATE_MSG) {
                  $result=MSG020;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  /* Album management end */
	  
	  /* Community management start*/
	  
	  function communityList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".COMMUNITY_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveCommunity($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];
			$upload_content = $data[4];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','COM',COMMUNITY_TABLE,'id');
                  $result=$admin->isAlreadyExist(COMMUNITY_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(COMMUNITY_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(COMMUNITY_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG025;
            } else if($result==UPDATE_MSG) {
                  $result=MSG026;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  /* Community management end */
	   /* Blog management start*/
	  
	  function blogList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".BLOG_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid390'>$page_title</div>
										  <div class='grid100'>$author</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveBlog($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
			$author = $data[1];
            $id = $data[2];
            $mode = $data[3];
            $content = $data[4];
                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`author`content`updated_date";
            $db_values="$page_title`$author`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','BLG',BLOG_TABLE,'id');
                  $result=$admin->isAlreadyExist(BLOG_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(BLOG_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(BLOG_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG027;
            } else if($result==UPDATE_MSG) {
                  $result=MSG028;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			return $result;
      }
	  
	  /* Blog management end */
	  /* Video management start*/
	  
	  function videoList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("page_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".VIDEO_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$page_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid436'>$page_title</div>
                                          <div class='grid100 acenter'>$enabled</div>
                                          <div class='grid80 acenter'>$edit</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
      
      function saveVideo($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $id = $data[1];
            $mode = $data[2];
            $content = $data[3];
			$upload_content = $data[4];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="page_title`content`updated_date";
            $db_values="$page_title`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','VED',VIDEO_TABLE,'id');
                  $result=$admin->isAlreadyExist(VIDEO_TABLE,'page_title',$page_title,'','');
            } else {                  
                  $result=$admin->isAlreadyExist(VIDEO_TABLE,'page_title',$page_title,'id',$id);
            }           
            
            if($result) {
                  return ERROR007;   
            }            
            
            $result = $admin -> insertElseUpdate(VIDEO_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG027;
            } else if($result==UPDATE_MSG) {
                  $result=MSG028;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
	  
	  /* Video management end */
	  /* Banner management start*/
	  
	  function bannerList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("banner_title",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".BANNER_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$banner_id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$banner_id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$banner_id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$banner_id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
						$banner_title = $admin -> getSubString($banner_title,80);
                        $banner_title = "<a href='javascript:void(0)' name='$banner_id' class='preview'>$banner_title</a>";
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid401'>$banner_title</div>
										  <div class='grid180'>$banner_type</div>
                                          <div class='grid90 acenter'>$edit</div>
                                          <div class='grid153 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  
	  function saveBanner($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $page_title = $data[0];
            $type = $data[1];
			$desc = $data[2];
			$url = $data[3];
			$id = $data[4];
			
			if(!$id){
				$id = $_SESSION['banner_id'];
			}
			
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="banner_title`banner_type`description`url`created_date";
            $db_values="$page_title`$type`$desc`$url`$created_date";
            
			$result = $admin -> insertElseUpdate(BANNER_TABLE,$db_fields,$db_values,'banner_id',$id);
            if($result==ADD_MSG) {
                  $result=MSG031;
            } else if($result==UPDATE_MSG) {
                  $result=MSG032;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			return $result;
	}
	  
	  
	  function getBannerTypeCombo($equal_id=''){
            $admin = new ADMIN;
            
            return $admin -> getCombo(BANNER_SETTINGS_TABLE,"banner_type","banner_type",$equal_id,"banner_setting_id","txt_medium","getBannerType","","","",'','');
            
      }
	  function getBannerDetails($id){
            $admin = new ADMIN;
            return $admin -> getDetails(BANNER_TABLE,"banner_id","$id");
      }
	  function deleteSpam($table_name,$field,$banner_id) {           
	  	    $admin = new ADMIN;
			mysql_query("delete from $table_name where $field is null");
			$path="../uploads/banner/$banner_id/";
                  if(is_dir($path)){
                        $admin->removeDir($path);   
                  }  
      }
	  /* Banner end */
	  function saveAboutUs($data) {
            $admin = new ADMIN;
            $data = explode("`",$data);
            $id=$data[0];            
            $meta_title=$data[1];
            $meta_keyword=$data[2];
            $meta_desc=$data[3];
            $content=$data[4];
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="content_about`meta_title`meta_keywords`meta_desc`created_date";
            $db_values="$content`$meta_title`$meta_keyword`$meta_desc`$created_date";
                       
            $result = $admin -> insertElseUpdate(ABOUT_US_TABLE,$db_fields,$db_values,'id',$id);
            
            //echo$sql = "update ".ABOUT_US_TABLE." set content_about='$content' where id = '10000' ";
           // mysql_query($sql);  
            $result = mysql_error();    
            if(!$result) {
                  $result = MSG012;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }      
            return $result;
      }
	  function saveHelp($data) {
            $admin = new ADMIN;
            $data = explode("`",$data);
            $id=$data[0];            
            $meta_title=$data[1];
            $meta_keyword=$data[2];
            $meta_desc=$data[3];
            $content=$data[4];
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="content_about`meta_title`meta_keywords`meta_desc`created_date";
            $db_values="$content`$meta_title`$meta_keyword`$meta_desc`$created_date";
                       
            $result = $admin -> insertElseUpdate(HELP_TABLE,$db_fields,$db_values,'id',$id);
            
            //echo$sql = "update ".ABOUT_US_TABLE." set content_about='$content' where id = '10000' ";
           // mysql_query($sql);  
            $result = mysql_error();    
            if(!$result) {
                  $result = MSG009;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }      
            return $result;
      }
	  function saveWhat($data) {
            $admin = new ADMIN;
            $data = explode("`",$data);
            $id=$data[0];            
            $meta_title=$data[1];
            $meta_keyword=$data[2];
            $meta_desc=$data[3];
            $content=$data[4];
			$created_date = date("Y-m-d H:i:s");
            
            $db_fields="content_about`meta_title`meta_keywords`meta_desc`created_date";
            $db_values="$content`$meta_title`$meta_keyword`$meta_desc`$created_date";
                       
            $result = $admin -> insertElseUpdate(WHAT_TABLE,$db_fields,$db_values,'id',$id);
            
            //echo$sql = "update ".ABOUT_US_TABLE." set content_about='$content' where id = '10000' ";
           // mysql_query($sql);  
            $result = mysql_error();    
            if(!$result) {
				if($id == "what"){
                 	 $result = MSG021;
				}else if($id == "mission"){
					$result = MSG023;
				}else if($id == "connect"){
					$result = MSG033;
				}else if($id == "help"){
					$result = MSG009;
				}else if($id == "about-us"){
					$result = MSG012;
				}else if($id == "contact-us"){
					$result = MSG035;
				}else if($id == "terms"){
					$result = MSG036;
				}else if($id == "privacy"){
					$result = MSG037;
				}else if($id == "fraud"){
					$result = MSG038;
				}
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }      
            return $result;
      }
	  function saveConnect($data) {
            $admin = new ADMIN;
            $data = explode("`",$data);
            $id=$data[0];            
            $meta_title=$data[1];
            $meta_keyword=$data[2];
            $meta_desc=$data[3];
            $facebook = $data[4];
			$linked_in =$data[5];
			$twitter = $data[6];
			$mail_in = $data[7];
			$digg = $data[8];
            $content=$data[9];
			$created_date = date("Y-m-d H:i:s");
            
            $db_fields="content_about`meta_title`meta_keywords`meta_desc`created_date`facebook`linked_in`twitter`mail_in`digg";
            $db_values="$content`$meta_title`$meta_keyword`$meta_desc`$created_date`$facebook`$linked_in`$twitter`$mail_in`$digg";
                       
            $result = $admin -> insertElseUpdate(WHAT_TABLE,$db_fields,$db_values,'id',$id);
            
            //echo$sql = "update ".ABOUT_US_TABLE." set content_about='$content' where id = '10000' ";
           // mysql_query($sql);  
            $result = mysql_error();    
            if(!$result) {
				if($id == "what"){
                 	 $result = MSG021;
				}else if($id == "mission"){
					$result = MSG023;
				}else if($id == "connect"){
					$result = MSG033;
				}else if($id == "help"){
					$result = MSG009;
				}else if($id == "about-us"){
					$result = MSG012;
				}else if($id == "contact-us"){
					$result = MSG035;
				}else if($id == "terms"){
					$result = MSG036;
				}else if($id == "privacy"){
					$result = MSG037;
				}else if($id == "fraud"){
					$result = MSG038;
				}
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }      
            return $result;
      }
	  
	   /* Donation list start */
	  
	  function donationList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("first_name",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".DONATION_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        $email = "<a href ='javascript:mailpop(\"$email\")'>$email</a>";
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$first_name</a>";
						$country = $admin -> getDetails(COUNTRY_TABLE,'country_id',$country);
						$country = $country['country_name'];
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid170'>$page_title</div>
                                          <div class='grid200'>$email</div>
                                          <div class='grid80'>$amount</div>
										  <div class='grid150'>$country</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  /* Donation list end */
	  
	   /* Feedback list start */
	  
	  function feedbackList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("name",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".FEED_BACK_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
						$sub_string_email = $admin -> getSubString($email,20);
                        $email = "<a href ='javascript:mailpop(\"$email\")'>$sub_string_email</a>";
						
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$name</a>";
						$country = $admin -> getDetails(COUNTRY_TABLE,'country_id',$country);
						$country = $country['country_name'];
                        
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid170'>$page_title</div>
                                          <div class='grid200'>$email</div>
                                          <div class='grid140'>$comment_status</div>
										  <div class='grid95'>$country</div>
                                          <div class='grid143 last'>$created_date</div>                                         
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  /* Feedback list end */
	  function email_list($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("email",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".EMAIL_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
						$sub_string_email = $admin -> getSubString($email,50);
                        $email = "<a href ='javascript:mailpop(\"$email\")'>$sub_string_email</a>";
						
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$email</a>";
						
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid440'>$email</div>
										  <div class='grid140 acenter'>$enabled</div>
										  <div class='grid183 acenter'>$created_date</div>
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  
	  function sendMailList($indx,$filter,$ser_field,$ser_type,$list_length,$ser_status) {
            $admin=new ADMIN;
            $qry = null;
                 
            $indx = $indx*$list_length;
            
            $qry .= $admin->getLikeSearchQuery("email",$filter); 
            $qry .= $admin->getSearchQuery("display_in`status","$ser_display_in`$ser_status");          
                        
            if($ser_field) {
                  $qry .= " order by $ser_field $ser_type";
            } else {
                  $qry .= " order by created_date desc";
            }
                              
            $query = "select * from ".SEND_MAIL_TABLE." where 1 $qry";
            $result = $admin->getExecuteQuery($query,$indx,$list_length,'rev_sno');
            $total_records = $result["total_records"];
            $indx = $result["indx"];
            $get_db = $result["exe_qry"];
            $sno = $result["sno"];
            
            $layout="<ul>";
            if($total_records) {
                  $sno = 0;
                  while($rs=mysql_fetch_array($get_db)) {
                        $sno++;
                        $sno%2 == 1 ? $bgcolor=" class='oddrowcolor'":$bgcolor=" class='evenrowcolor'";
                        extract($rs);
                        $checkbox="<input type='checkbox' name='check' value='$id' class='chkbox' />";
                        
                        if($status=='Active') {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Inactive')\"><img src='../images/site-admin/tick.png' alt='Make Disable' title='Make Disable' /></a>";
                        } else {
                              $enabled="<a href='javascript:void(0)' onclick=\"enable('$id','Active')\"><img src='../images/site-admin/publish.png' alt='Make Enable' title='Make Enable' /></a>";
                        }
						
						$edit = "	<a href='javascript:void(0)' name='$id' class='edit'>
										<img src='../images/site-admin/edit.png' alt='Edit' title='Edit' />	
									</a>";
                        
						$sub_string_email = $admin -> getSubString($email,70);
                        $email = $sub_string_email;
						
                        $created_date = $admin -> getNewDateFormat($created_date,'YMD',DATE_FORMAT,'-',DATE_REP);
                        $page_title = "<a href='javascript:void(0)' name='$id' class='preview'>$email</a>";
						
                        $layout .= "  <li$bgcolor>
                                          <div class='grid24 first'>$sno</div>
                                          <div class='grid20 acenter'>$checkbox</div>
                                          <div class='grid477'>$email</div>
										  <div class='grid130 acenter'>$edit</div>
										  <div class='grid163 acenter'>$created_date</div>
                                          <div class='clear'></div>
                                    </li>";
                  }                 
            } else {
                  $layout .= "<li class='norecords'>".ERROR003."</li>";
            }
            $layout .= "</ul>";
            $nav_result = $admin->Navigation($indx,$total_records,$list_length);
            $nav_process = "<div class='navigation-process' id='nav_process'></div>";
            $layout .= "<div class='list-footer'>$nav_result$nav_process</div>";    
            return $layout;
      }
	  
	  function sendNewsLetterMail(){
		  $admin = new ADMIN;
		  $qry = "select * from ".EMAIL_TABLE." where status = 'Active'";
		  $sql = mysql_query($qry);
		  $total = mysql_num_rows($sql);
		  $i=1;
		  while($fet = mysql_fetch_array($sql)){
			$email_list .= $fet['email'];
			if($total>$i){
				$email_list .= ",";
			}
			$i++;
		 }
		  return $email_list;
	  }
	  function sendMailToNewsLetter($email,$message_content) {
            $admin = new ADMIN;
            
            $subject = APPLICATION_NAME;
            $from_email = SUPPORT_EMAIL;
            $from_name = APPLICATION_NAME;
			$message_content = $admin -> removeBreak($message_content);
			$message = "<div style='border:15px solid #00CCFF;width:500px;'>
	<div style='color:#FF0000;font-weight:bold;padding:10px;text-align:center;'>Care Of Love News Letter</div>
    <div style='font-weight:bold;padding-top:10px'>Dear Subscriber,</div>
    <div style='padding-left:10px;' MAIL_STYLE>$message_content</div>
    
    <div style='color:#000000;font-weight:bold;padding:10px;text-align:center;'><a href='".BASEPATH."index.php?page=news-subscription&id=$id'>Click here</a> to Unsubscribe this newsletter</div>
	<div style='padding:10px;'>Best Regards, <br /><a href='".BASEPATH."' target='_blank' style='text-decoration:none;'>".APPLICATION_NAME." Team</a></div>
</div>";
			 $result = $admin -> send_mail($from_name, $from_email,$email, $subject, $message);
			//return $result;
      }
	  function saveMailContent($data) {
            $admin=new ADMIN;
			$split_data = $data;
            $data=explode("`",$data);
            $id = $data[0];
			$send_mail = $data[1]; 
			$mode = $data[2];
			$content = $data[3];
            
                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="email`content`updated_date";
            $db_values="$send_mail`$content`$created_date";
            if($mode=="New") {    
                  $db_fields.="`created_date";
                  $db_values.="`$created_date";
                  $id = $admin -> generateRandomNumber(5,'','',SEND_MAIL_TABLE,'id');
            }           
            
			$result = $admin -> insertElseUpdate(SEND_MAIL_TABLE,$db_fields,$db_values,'id',$id);
            if($result==ADD_MSG) {
                  $result=MSG022;
            } else if($result==UPDATE_MSG) {
                  $result=MSG022;
            } else {
                  $result = "<span class='emi newerror'>$result</span>";
            }
			$split_data = explode("`",$split_data);
			$explode_email = explode(",",$split_data[1]);
			$count = count($explode_email);
			for($i=0;$i<$count;$i++){
				$result = $admin -> sendMailToNewsLetter($explode_email[$i],$split_data[3]);
			}
            return $result;
      }
	  function saveGallery($data) {
            $admin=new ADMIN;
            $data=explode("`",$data);
            $id = $data[0];
            $mode = $data[1];
            $upload_content = $data[2];

                       
            $created_date = date("Y-m-d H:i:s");
            
            $db_fields="updated_date";
            $db_values="$created_date";
            
			$result = $admin -> insertElseUpdate(GALLERY_TABLE,$db_fields,$db_values,'id',$id);
			if($result==ADD_MSG) {
				  $result=MSG001;
			} else if($result==UPDATE_MSG) {
				  $result=MSG002;
			} else {
				  $result = "<span class='emi newerror'>$result</span>";
			}
			$flag = true;
			if($flag) {
                  $upld = new UPLOADCLASS;
                  $upld->updateImage($upload_content,$id); 
            }
            return $result;
      }
}     
?>